package com.yvon.maple.service.auth.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @author : Yvon
 * @since : 2021-08-24
 */
public enum CodeTypeEnum {

    SMS("sms", "smsCodeGenerator", "smsCodeProcessor", "短信验证码"),

    IMAGE("image", "imageCodeGenerator", "imageCodeProcessor", "图形验证码"),

    EMAIL("email", "emailCodeGenerator", "emailCodeProcessor", "邮箱验证码");

    private final String type;


    private final String generator;

    private final String processor;

    private final String name;


    CodeTypeEnum(String type, String generator, String processor,String name) {
        this.type = type;
        this.generator = generator;
        this.processor = processor;
        this.name = name;
    }


    public String getType() {
        return type;
    }

    public String getGenerator() {
        return generator;
    }

    public String getProcessor() {
        return processor;
    }

    public String getName() {
        return name;
    }

    public static CodeTypeEnum getByType(String type){
        for (CodeTypeEnum p : CodeTypeEnum.values()) {
            if (StringUtils.equals(type, p.getType())){
                return p;
            }
        }
        return null;
    }
}
